#!/usr/bin/rnv python
#:coding:utf-8
import MySQLdb, sys,time,datetime
date = float(time.time())-86400
ltime=time.localtime(date)
timeStr = time.strftime("%Y%m%d", ltime)
datestrftime=time.strftime('%Y-%m-%d',ltime)

# sql=sys.argv[1]

def select_mysql(sql):
    conn = MySQLdb.connect(host='10.0.0.142', user='daxmall_r', passwd='2hGUnCKoEuvkWNgRbvwo', db='daxmall', port=3306,
                           charset="utf8")

    cur = conn.cursor()
    reCount = cur.execute(sql)

    nRet = cur.fetchall()
    cur.close()

    conn.close()
    return nRet


def insert_mysql(sql):
    conn = MySQLdb.connect(host='121.201.68.21', port=3307, user='jiang', passwd='jiangwenhui', db='daxiangzhanshi',

                           charset='UTF8')

    cur = conn.cursor()

    cur.execute(sql)
    nRet = cur.fetchall()
    conn.commit()

    cur.close()

    conn.close()
    return nRet

if __name__ == "__main__":

    select = " SELECT SUM(s.total) AS 支付总金额  FROM ls_sub s      INNER JOIN ls_usr_addr_sub a ON a.`addr_order_id`=s.`addr_order_id`      INNER JOIN ls_usr_addr r ON r.`addr_id`=a.`addr_id`  WHERE s.update_date>=curdate() AND s.status != 5   ;"
    data = select_mysql(select)
